<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" id="form" name="form" action="{:u('update')}" method="post">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 用户组名 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="title" id="title" placeholder="用户组名"
                                           class="col-xs-10 col-sm-5" value="{$group.title}">
                                    <input type="hidden" name="id" id="id" value="{$group.id}">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">用户组名称，不能为空。</span>
											</span>
                                </div>
                            </div>
                            <if condition="$group.id neq 1">
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 是否启用 </label>
                                <div class="control-label no-padding-left col-sm-1">
                                    <label>
                                        <input name="status" id="status"
                                        <if condition="$group['status'] eq 1"> checked="checked"</if>
                                        class="ace ace-switch ace-switch-2" type="checkbox" />
                                        <span class="lbl"></span>
                                    </label>
                                </div>
                                <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">YES，启用；NO，禁用</span>
										</span>
                            </div>
                             <else />
                                <input name="status" id="status" value ="on" type="hidden" />
                             </if>
							<style>
								.auth_menu_list dl{margin-bottom:0px;}
								.auth_menu_list{ width:100%; border:1px solid #CCC; margin-bottom:10px; }
								.menuslists{width:200px; border:1px solid #ccc; border-radius:5px;z-index:998; background:#fff; position:absolute; margin-left:80px;box-shadow: 0px 0px 6px #ccc; display:none;}
								.auth_menu_list{ padding-bottom:10px;}
								.menuslists dl{ padding:10px; }
								.menuslists dl dd{ padding:5px; cursor:pointer}
								.menuslists dl dd:hover{ background:#efefef }
								.lmenuslists_list{ width:210px; border:1px solid #CCC; background:#fff;z-index:999; margin:-30px 0px 0px 170px;position:absolute; display:none;}
								.menuslists dl dd:hover .lmenuslists_list{ display:block }
							</style>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 用户组名 </label>
                                <div class="col-sm-9">
                                <volist name="options" id="vo">
                                    <div class="auth_menu_list">
										<div class="col-sm-12" style="font-size:14px; font-weight:bold; border-bottom:1px dashed #ccc; padding:0px 10px 10px 10px;">
                                            <div class="checkbox">
                                                    <label>
                                                        <input type="checkbox" id="menus_obj" class="ace" <?php if( authMenuDefault($group['auth_list'] , $vo['id'] , 1) === true ){ echo "checked"; } ?>>
                                                        <span class="lbl"> {$vo.title}</span>
                                                    </label>
                                            </div>
                                        </div>
                                        <notempty name="vo.list">
                                        <div class="col-sm-11">
                                            <volist name="vo.list" id="vo1">
                                        	<div class="col-sm-2">
                                                <div class="checkbox">
                                                    <label>
                                                        <input id="actions_obj" type="checkbox" class="ace" <?php if( authMenuDefault($group['auth_list'] , $vo1['id'] , 2) === true ){ echo "checked"; } ?>>
                                                        <span class="lbl"> {$vo1.title}</span>
                                                    </label>
                                                    <notempty name="vo1.list">
                                                    <a href="javascript:;">菜单</a>
                                                    <div class="menuslists">
                                                        <dl>
                                                        <volist name="vo1.list" id="vo2">
                                                            <dd>
                                                                <label>
                                                                    <input name="role_list[]" id="method_obj" value="{$vo.id}|{$vo1.id}|{$vo2.id}={$vo2.url}" <?php if( authMenuDefault($group['auth_list'] , $vo2['id'] , 3) === true ){ echo "checked"; } ?> type="checkbox" class="ace">
                                                                    <span class="lbl"> {$vo2.title}</span>
                                                                </label>
                                                                <notempty name="vo2.list">
                                                                <div class="lmenuslists_list">
                                                                	<dl>
                                                                    	<foreach name="vo2.list" item="vo3">
                                                                    	<dd>
                                                                        	<label>
                                                                                <input name="role_list[]" value="{$vo.id}|{$vo1.id}|{$vo3.id}={$vo3.url}" type="checkbox" class="ace" <?php if( authMenuDefault($group['auth_list'] , $vo3['id'] , 3) === true ){ echo "checked"; } ?>>
                                                                                <span class="lbl"> {$vo3.title}</span>
                                                                            </label>
                                                                        </dd>
                                                                        </foreach>
                                                                    </dl>
                                                                </div>
                                                                </notempty>
                                                            </dd>
                                                        </volist>
                                                        </dl>
                                                    </div>
                                                    </notempty>
                                                </div>
                                            </div>
                                            </volist>
                                        </div>
                                        </notempty>
                                        <div style="clear:both"></div>
									</div>
                                    </volist>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info submit" type="button">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<script src="__PUBLIC__/qwadmin/js/bootbox.js"></script>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(".children").click(function () {
        $(this).parent().parent().parent().parent().find(".father").prop("checked", true);
    })
    $(".father").click(function () {
        if (this.checked) {
            $(this).parent().parent().parent().parent().find(".children").prop("checked", true);
        } else {
            $(this).parent().parent().parent().parent().find(".children").prop("checked", false);
        }
    })
    $(".submit").click(function () {
        var title = $("#title").val();
        if (title == '') {
            bootbox.dialog({
                message: "用户组名称不能为空。",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
        $('#form').submit();

    });
	$('.auth_menu_list a').mouseover(function(){
		$('div.menuslists').each(function(){ $(this).hide() });
		$(this).parent().find('.menuslists').show();
	});
	$('input#menus_obj').click(function(){
		menus(this);
	});
	$('input#actions_obj').click(function(){
		actions(this);
	});
	function menus(obj) {
		var _self = obj;
		$(obj).closest('.auth_menu_list').find('input').each(function(){
			this.checked = _self.checked;
		});
	}
	function actions(obj){
		var _self = obj;
		$(obj).parent().parent().find('input').each(function(){
			this.checked = _self.checked;
		});
		var objes = $(obj).closest('.auth_menu_list');
		if( objes.find('input#actions_obj:checked').length > 0  ) {
			$(obj).closest('.auth_menu_list').find('input#menus_obj').attr('checked' , true );
		}
		if( objes.find('input#actions_obj:checked').length == 0 ) {
			$(obj).closest('.auth_menu_list').find('input#menus_obj').attr('checked' , false );
		}	
	}
	$('input#method_obj').click(function(){
		var _self = this;
		$(this).parent().parent().find('input').each(function(){
			this.checked = _self.checked;
		});
	});
</script>
</body>
</html>
